package com.session01.am;

import java.util.Scanner;

public class Game {
    Scanner input = new Scanner(System.in);

    public void startGame() {
        Persion p = new Persion();
        Computer c = new Computer();

        System.out.println("请输入你的名字:");
        p.userName = input.next();

        System.out.println("请选择电脑人物：1.七代火影鸣人 2.超级赛亚人悟空 3.海贼王路飞");
        int choose = input.nextInt();

        switch (choose) {
            case 1:
                c.computerName = "七代火影鸣人";
                System.out.println("电脑选择人物:" + c.computerName);
                break;
            case 2:
                c.computerName = "超级赛亚人悟空";
                System.out.println("电脑选择人物:" + c.computerName);
                break;
            case 3:
                c.computerName = "海贼王路飞";
                System.out.println("电脑选择人物:" + c.computerName);
        }

        String answer = "";
        int userCount = 0;
        int computerCount = 0;
        int draw = 0;

        while (true) {
            int userFist = p.showFist();
            int computerFist = c.showComputerFist();

            if ((userFist == 1 && computerFist == 3) ||
                    (userFist == 2 && computerFist == 1) ||
                    (userFist == 3 && computerFist == 2)) {
                System.out.println(p.userName + "，真厉害，你赢了，么么哒");
                userCount++;
            } else if ((userFist == 1 && computerFist == 2) ||
                    (userFist == 2 && computerFist == 3) ||
                    (userFist == 3 && computerFist == 1)) {
                System.out.println(p.userName + "，笨蛋，你输了~~");
                computerCount++;
            } else {
                System.out.println("平了~~~");
                draw++;
            }

            System.out.println("请问你要继续游戏吗？(y/n)");
            answer = input.next();

            if (answer.equalsIgnoreCase("n")) {
                break;
            }
        }

        System.out.println("游戏结束~~");
        System.out.println("一共游戏了" + (userCount + computerCount + draw) + "盘，你赢了" + userCount + "盘，你输入了" + computerCount + "盘，平了" + draw + "盘");
    }
}
